home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_313 / uucp / uucp1.lzh / src / GUtil / uident.c < prev    next >
C/C++ Source or Header  |  1990-01-10  |  925b  |  65 lines

  1.  
  2. /*
  3.  *  UIDENT.C
  4.  *
  5.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  6.  *
  7.  *  UIDENT files...
  8.  *
  9.  *  Searches for @($) <string> \0 and prints out
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <fcntl.h>
  14. #include "/version.h"
  15.  
  16. IDENT(".01");
  17.  
  18. void FindIdent();
  19.  
  20. char Buf[8192];
  21.  
  22. void
  23. main(ac, av)
  24. char **av;
  25. {
  26.     short i;
  27.     int fd;
  28.  
  29.     for (i = 1; i < ac; ++i) {
  30.     printf("%-15s ", av[i]);
  31.     fd = open(av[i], O_RDONLY);
  32.     if (fd > 0)
  33.         FindIdent(fd);
  34.     else
  35.         printf("(unable to open)");
  36.     puts("");
  37.     fflush(stdout);
  38.     if (fd > 0)
  39.         close(fd);
  40.     }
  41. }
  42.  
  43. void
  44. FindIdent(fd)
  45. int fd;
  46. {
  47.     long n;
  48.     long i;
  49.     long x = 0;
  50.  
  51.     while ((n = read(fd, Buf + x, sizeof(Buf) - x)) > 0) {
  52.     n += x;
  53.     for (i = n - 128; i >= 0; --i) {
  54.         if (Buf[i] == '@' && Buf[i+1] == '(' && Buf[i+2] == '$' && Buf[i+3] == ')') {
  55.         printf("%s", Buf + i);
  56.         }
  57.     }
  58.     x = 128;
  59.     if (n < x)
  60.         x = n;
  61.     movmem(Buf + n - x, Buf, x);
  62.     }
  63. }
  64.  
  65.